﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Hiro.Interfaces;
using LinFu.Reflection;

namespace Hiro.Loaders
{
    /// <summary>
    /// A class that automatically loads interface types as dependencies.
    /// </summary>
    internal class InterfaceDependencyLoader :
        IActionLoader<IList<IDependency>, Type>
    {
        public bool CanLoad(Type inputType)
        {
            return inputType.IsInterface && inputType.IsPublic;
        }

        public IEnumerable<Action<IList<IDependency>>> Load(Type serviceType)
        {
            yield return list => list.Add(new Dependency(string.Empty,
                                                         serviceType));
        }
    }
}
